package org.jivesoftware.smackx.workgroup.packet;

import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.provider.PacketExtensionProvider;
import org.xmlpull.v1.XmlPullParser;

public class QueueUpdate
  implements PacketExtension
{
  public static final String ELEMENT_NAME = "queue-status";
  public static final String NAMESPACE = "http://jabber.org/protocol/workgroup";
  private int position;
  private int remainingTime;

  public QueueUpdate(int paramInt1, int paramInt2)
  {
    this.position = paramInt1;
    this.remainingTime = paramInt2;
  }

  public String getElementName()
  {
    return "queue-status";
  }

  public String getNamespace()
  {
    return "http://jabber.org/protocol/workgroup";
  }

  public int getPosition()
  {
    return this.position;
  }

  public int getRemaingTime()
  {
    return this.remainingTime;
  }

  public String toXML()
  {
    StringBuilder localStringBuilder = new StringBuilder();
    localStringBuilder.append("<queue-status xmlns=\"http://jabber.org/protocol/workgroup\">");
    if (this.position != -1)
      localStringBuilder.append("<position>").append(this.position).append("</position>");
    if (this.remainingTime != -1)
      localStringBuilder.append("<time>").append(this.remainingTime).append("</time>");
    localStringBuilder.append("</queue-status>");
    return localStringBuilder.toString();
  }

  public static class Provider
  implements PacketExtensionProvider
  {
    public PacketExtension parseExtension(XmlPullParser paramXmlPullParser)
      throws Exception
    {
      int i = 0;
      int j = -1;
      int k = -1;
      if (i != 0)
        label9: return new QueueUpdate(j, k);
      paramXmlPullParser.next();
      String str = paramXmlPullParser.getName();
      if ((paramXmlPullParser.getEventType() == 2) && ("position".equals(str)));
      try
      {
        while (true)
        {
          int i1 = Integer.parseInt(paramXmlPullParser.nextText());
          j = i1;
        }
        if ((paramXmlPullParser.getEventType() == 2) && ("time".equals(str)));
      }
      catch (NumberFormatException localNumberFormatException2)
      {
        try
        {
          do
            while (true)
            {
              int l = Integer.parseInt(paramXmlPullParser.nextText());
              k = l;
            }
          while ((paramXmlPullParser.getEventType() != 3) || (!("queue-status".equals(str))));
          i = 1;
        }
        catch (NumberFormatException localNumberFormatException1)
        {
          break label9:
          localNumberFormatException2 = localNumberFormatException2;
        }
      }
    }
  }
}